import 'package:flutter/material.dart';
import 'package:sonora/components/background.dart';
import 'components/full_btn.dart';
import 'components/license_txt.dart';
import 'components/privacy_dialog.dart';

class LoginScreen extends StatelessWidget {
  const LoginScreen({Key? key}) : super (key: key);
  @override
  Widget build(BuildContext context) {
    Future<void> showListDialog() async {
      bool? isAgree = await showDialog<bool>(
        context: context,
        builder: (BuildContext context) {
          //使用AlertDialog会报错
          //return AlertDialog(content: child);
          return Dialog(
              shape: RoundedRectangleBorder(
                  borderRadius: BorderRadius.all(Radius.circular(2))
              ),
              child: PrivacyDialog()
          );
        },
      );
      if (isAgree != null) {
        print("点击了：$isAgree");
      }
    }

    return Background(
        child: Container(
          padding: EdgeInsets.only(
            bottom: 44.0
          ),
          child: Align(
              widthFactor: 2,
              heightFactor: 2,
              alignment: Alignment.topCenter,
              child: Column(
                children: [
                  SizedBox(
                    height: 170,
                  ),
                  Image(
                    width: 100,
                    height: 100,
                    image: AssetImage('assets/images/logo.png'),
                  ),
                  SizedBox(
                    height: 10,
                  ),
                  Text('Sonora',
                      style: TextStyle(color: Colors.white,fontSize: 24,decoration: TextDecoration.none,fontFamily: 'Galada',)),
                  Spacer(),
                  FullBtn(title: '456',
                      toLogin:() {
                        showListDialog();
                      },
                      toSign: () {
                    showListDialog();
                  }),
                  SizedBox(height: 48.0,width: double.infinity,),
                  LicenseTxt()
                ],
              )
          ),
        ),
        bgImage: 'assets/images/start_bg.png'
    );
  }
}